package com.gec.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.entity.SysCourse;
import com.gec.model.entity.SysCourseType;
import com.gec.model.entity.SysUser;
import com.gec.model.vo.SysCourseQueryVo;
import com.gec.model.vo.SysCourseTypeQueryVo;
import com.gec.system.mapper.SysCourseMapper;
import com.gec.system.service.SysCourseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 课程表 服务实现类
 * </p>
 *
 * @author lxj
 * @since 2024-03-07
 */
@Service
@Transactional
public class SysCourseServiceImpl extends ServiceImpl<SysCourseMapper, SysCourse> implements SysCourseService {

    @Override
    public IPage<SysCourse> selectPage(IPage<SysCourse> p1, SysCourseQueryVo sysCourseQueryVo) {
        return this.baseMapper.selectPage(p1,sysCourseQueryVo);
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        //1.查询出当前用户
        SysCourse  sysCourse = this.baseMapper.selectById(id);
        //2.设置状态
        sysCourse.setStatus(status);
        //3.更新
        this.baseMapper.updateById(sysCourse);
    }

    @Override
    public void updateRecommend(Long id, Integer recommend) {
        //1.查询出当前用户
        SysCourse  sysCourse = this.baseMapper.selectById(id);
        //2.设置状态
        sysCourse.setRecommend(recommend);
        //3.更新
        this.baseMapper.updateById(sysCourse);
    }
}
